home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CPPTASK.ARJ / TSKBIOS.ASM < prev    next >
Assembly Source File  |  1991-07-26  |  4KB  |  270 lines

  1. ;
  2. ;    CTask - BIOS INT 15 interrupt handler (IBM AT specific)
  3. ;
  4. ;    Public Domain Software written by
  5. ;        Thomas Wagner
  6. ;        Patschkauer Weg 31
  7. ;        D-1000 Berlin 33
  8. ;        West Germany
  9. ;
  10.     name    tskbios
  11.     .model    large
  12. ;
  13.     public    _tsk_install_bios
  14.     public    _tsk_remove_bios
  15. ;
  16.     include    tsk.mac
  17. ;
  18. intseg    segment at 0
  19. ;
  20.         org    15h*4
  21. pintofs        dw    ?        ; interrupt entry
  22. pintseg        dw    ?
  23.  
  24. intseg    ends
  25. ;
  26. ;
  27.     .data?
  28. ;
  29.     extrn    _ticks_per_sec: word
  30. ;
  31. floppy  flag    <>
  32. fdisk   flag    <>
  33. kbd     flag    <>
  34. ;
  35.     .data
  36. ;
  37. flag_tab    label    word
  38.     dw    offset fdisk
  39.     dw    offset floppy
  40.     dw    offset kbd
  41. ;
  42. ;
  43.     .code
  44. ;
  45.     extrn    _clear_flag_wait_set: far
  46.     extrn    _set_flag: far
  47.         extrn   _create_flag: far
  48.         extrn   _delete_flag: far
  49.         extrn   _t_delay: far
  50. ;
  51. post_save    label    dword        ; in CSEG to allow addressing
  52. psofs        dw    ?
  53. psseg        dw    ?
  54. ;
  55. ;----------------------------------------------------------------------
  56. ;
  57. ;    interrupt handler
  58. ;
  59. bios_int    proc    far
  60.         pushf
  61.     sti
  62.         cmp     ah,90h            ; WAIT
  63.         jb      bios_pass
  64.         cmp     ah,91h            ; POST
  65.         ja    bios_pass
  66.     cmp    al,2            ; fdisk/floppy/keyboard
  67.         jbe    process_bios
  68.     cmp    ah,91h
  69.     je    bios_pass
  70.     cmp    al,0fdh            ; floppy motor
  71.     jb    bios_pass
  72.     cmp    al,0feh            ; printer
  73.         jbe    process_bios
  74. ;
  75. bios_pass:
  76.     popf
  77.     jmp    cs:post_save
  78. ;
  79. process_bios:
  80.     popf
  81.     sti
  82.     push    es
  83.     push    ds
  84.     push    dx
  85.     push    cx
  86.     push    bx
  87.     push    ax
  88.     mov    bx,SEG dgroup
  89.     mov    ds,bx
  90.     mov    es,bx
  91. ;
  92.     cmp    al,2
  93.     jbe    flag_ops
  94. ;
  95.     cmp    al,0fdh
  96.     je    wait_motor
  97. ;
  98. ;    wait for printer ready.
  99. ;    delay for some ticks, then check printer.
  100. ;    CAUTION: this assumes the BIOS is *truly* AT compatible,
  101. ;         with the printer port address in DX on entry to INT15.
  102. ;
  103. wait_prn:
  104.     push    dx
  105.     mov    ax,3
  106.     push    ax
  107.     xor    ax,ax
  108.     push    ax
  109.     call    _t_delay
  110.     add    sp,4
  111.     pop    dx    
  112.     in    al,dx
  113.     test    al,80h
  114.     jz    wait_prn
  115.     stc
  116. ;
  117. bios_ret:
  118.     pop    ax
  119.     pop    bx
  120.     pop    cx
  121.     pop    dx
  122.     pop    ds
  123.     pop    es
  124.     ret    2
  125. ;
  126. ;    Wait for diskette motor start (1 sec.)
  127. ;
  128. wait_motor:
  129.     xor    ax,ax
  130.     push    ax
  131.     mov    ax,_ticks_per_sec
  132.     push    ax
  133.     call    _t_delay
  134.     add    sp,4
  135.     stc
  136.     jmp    bios_ret
  137. ;
  138. ;    Floppy/Fdisk/Keyboard wait/post
  139. ;
  140. flag_ops:
  141.     xor    bh,bh
  142.     mov    bl,al    
  143.     add    bx,bx
  144.     mov    bx,flag_tab[bx]
  145.     cmp    ah,90h
  146.     je    fl_wait
  147.     push    ds
  148.     push    bx
  149.     call    _set_flag
  150.     add    sp,4
  151.     clc
  152.     jmp    bios_ret
  153. ;
  154. fl_wait:
  155.     xor    dx,dx
  156.     cmp    al,2
  157.     je    fl_dowait
  158.     mov    dx,_ticks_per_sec
  159.     add    dx,dx
  160.     cmp    al,1
  161.     je    fl_dowait
  162.     mov    cx,dx
  163.     add    dx,cx
  164.     add    dx,cx
  165. fl_dowait:
  166.     xor    ax,ax
  167.     push    ax
  168.     push    dx
  169.     push    ds
  170.     push    bx
  171.     call    _clear_flag_wait_set
  172.     add    sp,8
  173.     cmp    ax,0
  174.     je    bios_ret
  175.     stc
  176.     jmp    bios_ret
  177. ;
  178. bios_int       endp
  179. ;
  180. ;------------------------------------------------------------------------
  181. ;
  182. ;    void far _tsk_remove_bios (void)
  183. ;
  184. ;    This routine un-installs the int handler.
  185. ;
  186. _tsk_remove_bios    proc    far
  187. ;
  188.     push    es
  189.     xor    ax,ax
  190.     mov    es,ax
  191.     assume    es:intseg
  192.         cli
  193.     mov    ax,cs:psofs        ; restore vector
  194.     mov    pintofs,ax
  195.     mov    ax,cs:psseg
  196.     mov    pintseg,ax
  197.         sti
  198.     assume    es:nothing
  199.     pop    es
  200. ;
  201.         mov     ax,offset floppy
  202.         push    ds
  203.         push    ax
  204.         call    _delete_flag
  205.         add     sp,4
  206. ;
  207.         mov     ax,offset fdisk
  208.         push    ds
  209.         push    ax
  210.         call    _delete_flag
  211.         add     sp,4
  212. ;
  213.         mov     ax,offset kbd
  214.         push    ds
  215.         push    ax
  216.         call    _delete_flag
  217.         add     sp,4
  218. ;
  219.         ret
  220. ;
  221. _tsk_remove_bios    endp
  222. ;
  223. ;----------------------------------------------------------------------
  224. ;
  225. ;    void far _tsk_install_bios (void)
  226. ;
  227. ;    This routine installs the int handler.
  228. ;
  229. _tsk_install_bios    proc    far
  230. ;
  231.         mov     ax,offset floppy
  232.         push    ds
  233.         push    ax
  234.         call    _create_flag
  235.         add     sp,4
  236. ;
  237.         mov     ax,offset fdisk
  238.         push    ds
  239.         push    ax
  240.         call    _create_flag
  241.         add     sp,4
  242. ;
  243.         mov     ax,offset kbd
  244.         push    ds
  245.         push    ax
  246.         call    _create_flag
  247.         add     sp,4
  248. ;
  249.         push    es
  250.     xor    ax,ax
  251.     mov    es,ax            ; establish addressing for intseg
  252.     assume    es:intseg
  253. ;
  254.     mov    ax,pintofs        ; save old timer int addr
  255.     mov    psofs,ax
  256.     mov    ax,pintseg
  257.     mov    psseg,ax
  258.     cli
  259.     mov    pintofs,offset bios_int ; set new timer int addr
  260.     mov    pintseg,cs
  261.     sti
  262.     assume    es:nothing
  263.         pop     es
  264.     ret
  265. ;
  266. _tsk_install_bios    endp
  267. ;
  268.     end
  269.  
  270.